package com.spzx.order.controller;

import com.spzx.common.core.web.controller.BaseController;
import com.spzx.common.core.web.domain.AjaxResult;
import com.spzx.common.rabbit.constant.MqConst;
import com.spzx.common.rabbit.service.RabbitService;
import com.spzx.order.configure.DeadLetterMqConfig;
import com.spzx.order.configure.DelayedMqConfig;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author ChenXing
 * @Description   Mq 测试代码
 * @Create 2024/8/16 18:23
 */


@Tag(name = "Mq接口管理")
@RestController
@RequestMapping("/mq")
public class MqController extends BaseController {

    @Autowired
    private RabbitService rabbitService;

    @GetMapping("/sendMessage")
    public AjaxResult sendMessage(){
     // rabbitService.sendMessage(MqConst.EXCHANGE_TEST,MqConst.ROUTING_TEST,"Hello RabbitMQ");
        // 制造发送失败的消息
      rabbitService.sendMessage(MqConst.EXCHANGE_TEST,"MqConst.ROUTING_TEST","Hello RabbitMQ");
      return success();
    }

    @GetMapping("/sendDelayMessage")
    public AjaxResult sendDelayMessage()
    {
        rabbitService.sendDelayMessage(DelayedMqConfig.exchange_delay, DelayedMqConfig.routing_delay, "hello delay");
        return success();
    }


    @GetMapping("/sendDeadMessage")
    public AjaxResult sendDeadMessage()
    {
        rabbitService.sendDeadMessage(DeadLetterMqConfig.exchange_dead, DeadLetterMqConfig.routing_dead_1, "hello dead");
        return success();
    }



}
